package com.leyuangame.core.websocket;

import com.leyuangame.core.websocket.handler.GameEventHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.tio.server.ServerGroupContext;
import org.tio.websocket.server.WsServerStarter;
import org.tio.websocket.server.handler.IWsMsgHandler;

import java.io.IOException;

public class GameServer {
	private ServerGroupContext serverGroupContext;
	private WsServerStarter wsServerStarter;
	/**
	 *
	 * @author tanyaowu
	 */
	public GameServer(int port,IWsMsgHandler gameEventHandler) throws IOException {
		wsServerStarter = new WsServerStarter(port, gameEventHandler);
		serverGroupContext = wsServerStarter.getServerGroupContext();
	}

	/**
	 * @return the serverGroupContext
	 */
	public ServerGroupContext getServerGroupContext() {
		return serverGroupContext;
	}

	public WsServerStarter getWsServerStarter() {
		return wsServerStarter;
	}

	public void start() throws IOException {
		wsServerStarter.start();
	}
}
